package maurice;

import java.util.*;

public class Sequence {
	private MovementSet moveset;
	private ArrayList<Movement> sequence;
	private int currentMovement;
	
	public Sequence(MovementSet moveset, int nb){
		this.moveset = moveset;
		sequence = new ArrayList<Movement>();
		addMovement(nb);
		currentMovement = 0;
	}
	
	public Movement nextMovement(){
		Movement movement = null;
		
		if (currentMovement < sequence.size()){
			movement = getCurrentMovement();
			currentMovement++;
		}
			
		return movement;
	}
	
	public void addMovement(int nb){
		for (int i=0; i<nb; i++){
			sequence.add(moveset.get((int) (Math.random() * moveset.size())));
		}
	}
	
	public void reset(){
		currentMovement = 0;
	}
	
	private Movement getCurrentMovement(){
		return sequence.get(currentMovement);
	}
	
	public boolean hasNext(){
		if (currentMovement == sequence.size())
			return false;
		else
			return true;
	}
}
